package logic

import (
	"context"

	"github.com/comfygpt-backend-go/service/component-rpc/component"
	"github.com/comfygpt-backend-go/service/component-rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteComponentLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteComponentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteComponentLogic {
	return &DeleteComponentLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DeleteComponentLogic) DeleteComponent(in *component.ComponentIdRequest) (*component.Empty, error) {
	err := l.svcCtx.ComponModel.Delete(l.ctx, in.Id)
	if err != nil {
		return nil, err
	}

	return &component.Empty{}, nil
}
